package cn.schoolwow.quickdao.test.module.business.user.dml.userRole.testcase;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.test.entity.Department;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import org.junit.Assert;

import java.util.ArrayList;
import java.util.List;

public class DeleteDepartmentTestCaseFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);

        dao.rebuild(Department.class);
        List<Department> departmentList = new ArrayList<>();
        for(int i=0;i<10;i++){
            Department department = new Department();
            department.setName("部门"+i);
            department.setParentId(0L);
            departmentList.add(department);
        }
        dao.insert(departmentList);

        int effect = dao.delete(departmentList);
        Assert.assertEquals(10, effect);
    }

    @Override
    public String name() {
        return "删除部门列表测试用例";
    }
}
